<template>
  <div class="dialog">
    <div class="dialog-wrap">
      <div class="dialog-header">
        <slot name="header"></slot>
        <span class="dialog-header-close" @click="$emit('update:isShow', false)"
          >×</span
        >
      </div>
      <div class="dialog-body">
        <slot></slot>
      </div>
      <div class="dialog-footer">
        <slot name="footer"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Dialog",
  props: {
    isShow: {
      type: Boolean,
      require: true,
    },
  },
};
</script>

<style lang='less' scoped>
.dialog {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  .dialog-wrap {
    position: absolute;
    width: 380px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    overflow: hidden;
    .dialog-header {
      display: flex;
      justify-content: space-between;
      padding: 10px;
      font-size: 20px;
      .dialog-header-close {
        font-size: 18px;
        cursor: pointer;
      }
    }

    .dialog-body {
      margin: 10px;
      text-align: center;
      font-size: 16px;
    }
    .dialog-footer {
      float: right;
      margin: 10px;
      font-size: 14px;
      button {
        margin-left: 10px;
        border-radius: 3px;
        color: #fff;
        padding: 2px 5px;
        cursor: pointer;
      }
      button:nth-child(1) {
        background-color: lightgreen;
        border: 1px solid green;
      }
      button:nth-child(1):hover {
        background-color: green;
      }
      button:nth-child(2) {
        background-color: lightcoral;
        border: 1px solid red;
      }
      button:nth-child(2):hover {
        background-color: red;
      }
    }
  }
}
</style>